function result = mimo_plot(a, b, c, d, e, f, g, hhh, k, csvFileName)
    %h��ʾ�������Լ��趨�����������,hhh����0Ϊ�Զ�������hhh����1Ϊ�ֶ�����

    n = a;
    h = sqrt(1/2) * (randn(n, 2) + 1i * randn(n, 2));
    w = sqrt(1/2) * (randn(n, 2) + 1i * randn(n, 2));
    snr = c;
    c1 = [0, 0, 0, 0];
    rcc1 = [0, 0, 0, 0];

    if (hhh == 1)
        c1(1) = d;
        c1(2) = e;
        c1(3) = f;
        c1(4) = g;
        m = complex(zeros(1, 4));
        %%4qam
        if (b == 1)
            %4qam
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = (1 + 1i) / sqrt(2);
                    else
                        m(i) = (-1 + 1i) / sqrt(2);
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = (-1 - 1i) / sqrt(2);
                    else
                        m(i) = (1 - 1i) / sqrt(2);
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            s = complex(zeros(1, 4));
            s(1) = (1 + 1i) / sqrt(2);
            s(2) = (-1 + 1i) / sqrt(2);
            s(3) = (-1 - 1i) / sqrt(2);
            s(4) = (1 - 1i) / sqrt(2);
            s = [1 + 1i -1 + 1i -1 - 1i 1 - 1i] / sqrt(2);
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %defourqam
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == (1 + 1i) / sqrt(2))
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == (-1 + 1i) / sqrt(2))
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == (-1 - 1i) / sqrt(2))
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == (1 - 1i) / sqrt(2))
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = unifrnd(0, 1, lin, col); %(0,1)均匀分布中随机抽取一些数作为输入

                    for i = 1:col

                        if c2(1, i) >= 0.5
                            c2(1, i) = 1;
                        else
                            c2(1, i) = 0;
                        end

                    end

                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = (1 + 1i) / sqrt(2);
                            else
                                m(i) = (-1 + 1i) / sqrt(2);
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = (-1 - 1i) / sqrt(2);
                            else
                                m(i) = (1 - 1i) / sqrt(2);
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    % s = complex(zeros(1, 4));
                    % s(1) = (1 + 1i) / sqrt(2);
                    % s(2) = (-1 + 1i) / sqrt(2);
                    % s(3) = (-1 - 1i) / sqrt(2);
                    % s(4) = (1 - 1i) / sqrt(2);
                    s = [1 + 1i -1 + 1i -1 - 1i 1 - 1i] / sqrt(2);
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == (1 + 1i) / sqrt(2))
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == (-1 + 1i) / sqrt(2))
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == (-1 - 1i) / sqrt(2))
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == (1 - 1i) / sqrt(2))
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        %%4ask
        if (b == 2)
            %4ask
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = -1;
                    else
                        m(i) = -1/3;
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = 1/3;
                    else
                        m(i) = 1;
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            s = zeros(1, 4);
            s(1) = -1;
            s(2) = -1/3;
            s(3) = 1/3;
            s(4) = 1;
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %de4ask
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == -1)
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == -1/3)
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == 1/3)
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == 1)
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = unifrnd(0, 1, lin, col); %(0,1)均匀分布中随机抽取一些数作为输入

                    for i = 1:col

                        if c2(1, i) >= 0.5
                            c2(1, i) = 1;
                        else
                            c2(1, i) = 0;
                        end

                    end

                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = -1;
                            else
                                m(i) = -1/3;
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = 1/3;
                            else
                                m(i) = 1;
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    s = zeros(1, 4);
                    s(1) = -1;
                    s(2) = -1/3;
                    s(3) = 1/3;
                    s(4) = 1;
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == -1)
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == -1/3)
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == 1/3)
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == 1)
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        %%4fsk
        if (b == 3)
            %4fsk
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = -1;
                    else
                        m(i) = -1/3;
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = 1/3;
                    else
                        m(i) = 1;
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            s = zeros(1, 4);
            s(1) = -1;
            s(2) = -1/3;
            s(3) = 1/3;
            s(4) = 1;
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %de4fsk
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == -1)
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == -1/3)
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == 1/3)
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == 1)
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = c1;
                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    %4fsk
                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = -1;
                            else
                                m(i) = -1/3;
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = 1/3;
                            else
                                m(i) = 1;
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    s = zeros(1, 4);
                    s(1) = -1;
                    s(2) = -1/3;
                    s(3) = 1/3;
                    s(4) = 1;
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == -1)
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == -1/3)
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == 1/3)
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == 1)
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        result = rcc1;
    end

    if (hhh == 0)
        c2 = unifrnd(0, 1, 1, 4); %(0,1)均匀分布中随机抽取一些数作为输入

        for i = 1:4

            if c2(1, i) >= 0.5
                c2(1, i) = 1;
            else
                c2(1, i) = 0;
            end

        end

        c1 = c2;
        m = complex(zeros(1, 4));
        %%4qam
        if (b == 1)
            %4qam
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = (1 + 1i) / sqrt(2);
                    else
                        m(i) = (-1 + 1i) / sqrt(2);
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = (-1 - 1i) / sqrt(2);
                    else
                        m(i) = (1 - 1i) / sqrt(2);
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            % s = complex(zeros(1, 4));
            % s(1) = (1 + 1i) / sqrt(2);
            % s(2) = (-1 + 1i) / sqrt(2);
            % s(3) = (-1 - 1i) / sqrt(2);
            % s(4) = (1 - 1i) / sqrt(2);
            s = [1 + 1i -1 + 1i -1 - 1i 1 - 1i] / sqrt(2);
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %defourqam
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == (1 + 1i) / sqrt(2))
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == (-1 + 1i) / sqrt(2))
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == (-1 - 1i) / sqrt(2))
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == (1 - 1i) / sqrt(2))
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = unifrnd(0, 1, lin, col); %(0,1)均匀分布中随机抽取一些数作为输入

                    for i = 1:col

                        if c2(1, i) >= 0.5
                            c2(1, i) = 1;
                        else
                            c2(1, i) = 0;
                        end

                    end

                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = (1 + 1i) / sqrt(2);
                            else
                                m(i) = (-1 + 1i) / sqrt(2);
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = (-1 - 1i) / sqrt(2);
                            else
                                m(i) = (1 - 1i) / sqrt(2);
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    % s = complex(zeros(1, 4));
                    % s(1) = (1 + 1i) / sqrt(2);
                    % s(2) = (-1 + 1i) / sqrt(2);
                    % s(3) = (-1 - 1i) / sqrt(2);
                    % s(4) = (1 - 1i) / sqrt(2);
                    s = [1 + 1i -1 + 1i -1 - 1i 1 - 1i] / sqrt(2);
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == (1 + 1i) / sqrt(2))
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == (-1 + 1i) / sqrt(2))
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == (-1 - 1i) / sqrt(2))
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == (1 - 1i) / sqrt(2))
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        %%4ask
        if (b == 2)
            %4ask
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = -1;
                    else
                        m(i) = -1/3;
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = 1/3;
                    else
                        m(i) = 1;
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            s = zeros(1, 4);
            s(1) = -1;
            s(2) = -1/3;
            s(3) = 1/3;
            s(4) = 1;
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %de4ask
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == -1)
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == -1/3)
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == 1/3)
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == 1)
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = unifrnd(0, 1, lin, col); %(0,1)均匀分布中随机抽取一些数作为输入

                    for i = 1:col

                        if c2(1, i) >= 0.5
                            c2(1, i) = 1;
                        else
                            c2(1, i) = 0;
                        end

                    end

                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = -1;
                            else
                                m(i) = -1/3;
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = 1/3;
                            else
                                m(i) = 1;
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    s = zeros(1, 4);
                    s(1) = -1;
                    s(2) = -1/3;
                    s(3) = 1/3;
                    s(4) = 1;
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == -1)
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == -1/3)
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == 1/3)
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == 1)
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        %%4fsk
        if (b == 3)
            %4fsk
            N = length(c1);
            n = N / 2;

            for i = 1:n

                if (c1(2 * i - 1) == 0)

                    if (c1(2 * i) == 0)
                        m(i) = -1;
                    else
                        m(i) = -1/3;
                    end

                else

                    if (c1(2 * i) == 0)
                        m(i) = 1/3;
                    else
                        m(i) = 1;
                    end

                end

            end

            cc1 = m;

            %Alamouti
            m1 = cc1(1);
            m2 = -conj(cc1(2));
            m3 = cc1(2);
            m4 = conj(cc1(1));
            s1 = [m1, m2; m3, m4];

            %recieve
            y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

            %decode
            s = zeros(1, 4);
            s(1) = -1;
            s(2) = -1/3;
            s(3) = 1/3;
            s(4) = 1;
            %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
            min1 = 0;
            min2 = 0;
            %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
            DD = 10 ^ 10;

            for i = 1:4

                for t = 1:4
                    ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                    yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                    if (yy < DD)
                        DD = yy;
                        min1 = i;
                        min2 = t;
                    end

                end

            end

            u = complex([0, 0]);
            u(1) = s(min1);
            u(2) = s(min2);
            ccc1 = u;

            %de4fsk
            l = length(ccc1);

            for i = 1:l

                if (ccc1(i) == -1)
                    m(2 * i - 1) = 0; m(2 * i) = 0;
                end

                if (ccc1(i) == -1/3)
                    m(2 * i - 1) = 0; m(2 * i) = 1;
                end

                if (ccc1(i) == 1/3)
                    m(2 * i - 1) = 1; m(2 * i) = 0;
                end

                if (ccc1(i) == 1)
                    m(2 * i - 1) = 1; m(2 * i) = 1;
                end

            end

            rcc1 = real(m);

            %plot
            col = 4;
            lin = 1;

            for snr = -10:20
                tt = 0;

                for o = 1:k
                    c2 = unifrnd(0, 1, lin, col); %(0,1)均匀分布中随机抽取一些数作为输入

                    for i = 1:col

                        if c2(1, i) >= 0.5
                            c2(1, i) = 1;
                        else
                            c2(1, i) = 0;
                        end

                    end

                    h = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从复高斯分布的信道增益
                    w = sqrt(1/2) * (randn(1, 2) +1i * randn(1, 2)); %生成服从高斯分布的白噪声

                    %4fsk
                    N = length(c2);
                    n = N / 2;

                    for i = 1:n

                        if (c2(2 * i - 1) == 0)

                            if (c2(2 * i) == 0)
                                m(i) = -1;
                            else
                                m(i) = -1/3;
                            end

                        else

                            if (c2(2 * i) == 0)
                                m(i) = 1/3;
                            else
                                m(i) = 1;
                            end

                        end

                    end

                    cc1 = m;

                    %Alamouti
                    m1 = cc1(1);
                    m2 = -conj(cc1(2));
                    m3 = cc1(2);
                    m4 = conj(cc1(1));
                    s1 = [m1, m2; m3, m4];

                    %recieve
                    y1 = sqrt(10 ^ (snr / 10) / 2) * h * s1 + w;

                    s = zeros(1, 4);
                    s(1) = -1;
                    s(2) = -1/3;
                    s(3) = 1/3;
                    s(4) = 1;
                    %ss=[s(1),s(1);-1*conj(s(1)),conj(s(1))];
                    min1 = 0;
                    min2 = 0;
                    %minn=abs(trace((y-sqrt(10^(snr/10)/2)*h*ss)*(y-sqrt(10^(snr/10)/2)*h*ss)'));
                    DD = 10 ^ 10;

                    for i = 1:4

                        for t = 1:4
                            ss = [s(i), -1 * conj(s(t)); s(t), conj(s(i))];
                            yy = abs(trace((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss) * ((y1 - sqrt(10 ^ (snr / 10) / 2) * h * ss)')));

                            if (yy < DD)
                                DD = yy;
                                min1 = i;
                                min2 = t;
                            end

                        end

                    end

                    u(1) = s(min1);
                    u(2) = s(min2);
                    p = u;

                    l = length(p);

                    for i = 1:l

                        if (p(i) == -1)
                            m(2 * i - 1) = 0; m(2 * i) = 0;
                        end

                        if (p(i) == -1/3)
                            m(2 * i - 1) = 0; m(2 * i) = 1;
                        end

                        if (p(i) == 1/3)
                            m(2 * i - 1) = 1; m(2 * i) = 0;
                        end

                        if (p(i) == 1)
                            m(2 * i - 1) = 1; m(2 * i) = 1;
                        end

                    end

                    rc1 = m;

                    if isequal(rc1, c2)
                        tt = tt + 1;
                    end

                end

                tt = tt / k;
                u(snr + 11) = tt;
            end

            n = -10:20;
            csvwrite(csvFileName, [u; n]); % PATCH: this line source code is `semilogx(n,u);`
        end

        result = rcc1;
    end

    result = rcc1;
end
